/**
*      author: Y_Yao
*      created: 2025-02-28 11:29:49
**/

#include<bits/stdc++.h>

#define int LL
using namespace std;
using LL = long long;
const LL LLINF = 1e18;
const int INF = 0x3f3f3f3f;
const int N = 5e5 + 7;
string s;
int n,q;

void solve()
{
    cin >> n;
    cin >> s;
    vector<pair<int,char>> a(n); 
    for(int i = 0;i < s.size();i++)
    {
        a[i] = {0,s[i]};
    }
    cin >> q;
    optional<pair<int,int>> cur = nullopt;
    for(int j = 0;j < q;j++)
    {
        int t,i;
        char c;
        cin >> t >> i >> c;
        if(t == 1)
        {
            a[i-1] = {j,c};
        }
        else // small to big
        {
            cur = {j,t};
        }
    }

    for(auto& [time,c]:a)
    {
        if(!cur || time > cur->first)
        {
            cout << c;
        }
        else if(cur->second == 2)
        {
            cout << (char)tolower(c);
        }
        else cout << (char)toupper(c);
    }
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    int t = 1;
    //cin >> t;
    while(t--)
    {
        solve();
    }
    return 0;
}